<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
    <head>
        <meta charset="UTF-8">
        <title>欢迎页面</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="shortcut icon" type="image/x-icon" th:href="@{/favicon.ico}" />
        <link rel="stylesheet" th:href="@{/css/font.css}">
        <link rel="stylesheet" th:href="@{css/xadmin.css}">
        <script type="text/javascript" th:src="@{/lib/jquery/jquery.min.js}"></script>
        <script th:src="@{/lib/layui/layui.js}"></script>
        <script th:src="@{/lib/echarts/echarts.min.js}"></script>
        <script type="text/javascript" th:src="@{/js/xadmin.js}"></script>
        <link rel="stylesheet" th:href="@{/css/animate.min.css}">
    </head>
    <body>
        <div class="x-body animated fadeIn">
            <blockquote class="layui-elem-quote">欢迎：
                <span><shiro:principal property="username"/></span>！当前时间: [[${#dates.format(new java.util.Date().getTime(), 'yyyy-MM-dd HH:mm:ss')}]]</blockquote>
            <fieldset class="layui-elem-field">
                <legend>数据统计</legend>
                <div class="layui-field-box">
                    <div class="layui-col-md12">
                        <div class="layui-card">
                            <div class="layui-card-body">
                                <div class="layui-carousel x-admin-carousel x-admin-backlog" lay-anim="" lay-indicator="inside" lay-arrow="none" style="width: 100%; height: 90px;">
                                    <div carousel-item="">
                                        <ul class="layui-row layui-col-space10 layui-this">
                                            <li class="layui-col-xs2">
                                                <a href="#" onclick="openTab('用户管理', '/user/index')" class="x-admin-backlog-body">
                                                    <h3>用户数</h3>
                                                    <p>
                                                        <cite th:text="${userCount}"></cite>
                                                    </p>
                                                </a>
                                            </li>
                                            <li class="layui-col-xs2">
                                                <a href="#" onclick="openTab('角色管理', '/role/index')" class="x-admin-backlog-body">
                                                    <h3>角色数</h3>
                                                    <p>
                                                        <cite th:text="${roleCount}"></cite>
                                                    </p>
                                                </a>
                                            </li>
                                            <li class="layui-col-xs2">
                                                <a href="#" onclick="openTab('菜单管理', '/menu/index')" class="x-admin-backlog-body">
                                                    <h3>菜单数</h3>
                                                    <p>
                                                        <cite th:text="${menuCount}"></cite>
                                                    </p>
                                                </a>
                                            </li>
                                            <li class="layui-col-xs2">
                                                <a href="#" onclick="openTab('登录日志', '/log/login/index')" class="x-admin-backlog-body">
                                                    <h3>登录日志</h3>
                                                    <p>
                                                        <cite th:text="${loginLogCount}"></cite>
                                                    </p>
                                                </a>
                                            </li>
                                            <li class="layui-col-xs2">
                                                <a href="#" onclick="openTab('操作日志', '/log/sys/index')" class="x-admin-backlog-body">
                                                    <h3>操作日志</h3>
                                                    <p>
                                                        <cite th:text="${sysLogCount}"></cite>
                                                    </p>
                                                </a>
                                            </li>
                                            <li class="layui-col-xs2">
                                                <a href="#" onclick="openTab('在线人数', '/online/index')" class="x-admin-backlog-body">
                                                    <h3>在线人数</h3>
                                                    <p>
                                                        <cite th:text="${userOnlineCount}"></cite>
                                                    </p>
                                                </a>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </fieldset>
            <fieldset class="layui-elem-field">
                <legend>最近登录</legend>
                <div class="layui-field-box">
                    <div id="main" style="width: 100%;height:400px;"></div>
                </div>
            </fieldset>
        </div>
        <script type="application/javascript">
            layui.use('element', function(){
                // 基于准备好的dom，初始化echarts实例
                var myChart = echarts.init(document.getElementById('main'));
                // 指定图表的配置项和数据
                option = {
                    title: {
                        text: '近七天登陆次数统计图',
                        left: 'center'
                    },
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: { // 坐标轴指示器，坐标轴触发有效
                            type: 'none' // 默认为直线，可选为：'line' | 'shadow'
                        }
                    },
                    xAxis: {
                        type: 'category',
                        data:  getWeekList()
                    },
                    yAxis: {
                        type: 'value'
                    },
                    series: [{
                        data: [],
                        type: 'line'
                    }]
                };
                layui.$.get('/weekLoginCount', function (data) {
                    option.series[0].data = data;
                    // 使用刚指定的配置项和数据显示图表。
                    myChart.setOption(option);
                });
            });
        </script>
    </body>
</html>